<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
	<meta name="format-detection" content="telephone=no">
	<meta name="author" content="演示SHOP Team">
	<meta name="copyright" content="演示SHOP">
	<title>${message("shop.payment.prePay")} - 演示电商</title>
	<link href="${base}/favicon.ico" rel="icon">
	<link href="${base}/resources/common/css/bootstrap.css" rel="stylesheet">
	<!--[if lt IE 9]>
		<script src="${base}/resources/common/js/html5shiv.js"></script>
		<script src="${base}/resources/common/js/respond.js"></script>
	<![endif]-->
	<script src="${base}/resources/common/js/jquery.js"></script>
	<script src="${base}/resources/common/js/bootstrap.js"></script>
	<style>
		.prePay {
			display: none;
		}
		
		.prePay p {
			margin-top: 50px;
			font-size: 14px;
			text-align: center;
			position: relative;
		}
		
		.prePay p span {
			width: 100px;
			height: 50px;
			position: absolute;
			top: -40px;
			right: -20px;
			background: url() no-repeat center center;
			background-size: contain;
		}
		
		.prePay div {
			width: 100px;
			height: 100px;
			margin: 100px auto;
		}
		
		.prePay div.iphone {
			background: url() no-repeat center center;
			background-size: contain;
		}
		
		.prePay div.android {
			background: url() no-repeat center center;
			background-size: contain;
		}
	</style>
	[#noautoesc]
		[#escape x as x?js_string]
			<script>
			$().ready(function() {
			
				var $prePay = $(".prePay");
				var $tips = $("#tips");
				var userAgent = navigator.userAgent.toLowerCase();
				var paymentTransactionSn = ${paymentTransactionSn}
				
				if (/micromessenger/gi.test(userAgent)) {
					$prePay.show();
					if (/iphone|ipad|ipod/gi.test(userAgent)) {
						$tips.removeClass("android").addClass("iphone");
					} else if (/android/gi.test(userAgent)) {
						$tips.removeClass("iphone").addClass("android");
					}
					// 检查是否支付成功
					setInterval(function() {
						$.ajax({
							url: "${base}/payment/is_pay_success",
							data: {
								paymentTransactionSn: paymentTransactionSn
							},
							type: "GET",
							dataType: "json",
							cache: false,
							success: function(data) {
								if (data.isPaySuccess) {
									location.href = "${base}/payment/post_pay_" + paymentTransactionSn;
								}
							}
						});
					}, 1000);
				} else {
					location.href = "${payUrl}";
				}
			
			});
			</script>
		[/#escape]
	[/#noautoesc]
</head>
<body class="prePay">
	<p>
		<span></span>
		[#noautoesc]${message("shop.payment.weixinPublicPaymentHint")}[/#noautoesc]
	</p>
	<div id="tips"></div>
</body>
</html>